package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("api/v1/material")
public class WmMaterialController {

    @Autowired
    WmMaterialService materialService;

    /**
     * 素材上传
     * @param file  用来接受文件
     * @return
     */
    @PostMapping("upload_picture")
    public ResponseResult upload(@RequestParam("multipartFile") MultipartFile file){
        return materialService.upload(file);
    }

    /**
     * 素材列表
     * @param dto
     * @return
     */
    @PostMapping("list")
    public ResponseResult query(@RequestBody WmMaterialDto dto){
        return materialService.query(dto);
    }
}
